import request from "@/utils/request";

import type {GetTradeMarkListApiResponse,TrademarkItem,TrademarkList} from './model/trademarkModel'

// 使用枚举定义接口地址
enum Api{
    getTrademarkList = '/admin/product/baseTrademark',
    getAllTrademarkList = "/admin/product/baseTrademark/getTrademarkList",
    saveTrademark = "/admin/product/baseTrademark/save",
    updateTrademark = "/admin/product/baseTrademark/update",
    removeTrademark = "/admin/product/baseTrademark/remove"
}

// 获取品牌分页列表
export const getTrademarkListApi = (page:number,limit:number)=>{
    return request.get<any,GetTradeMarkListApiResponse>(`${Api.getTrademarkList}/${page}/${limit}`)
}

// 获取所有品牌列表
export const getAllTrademarkListApi = ()=>{
    return request.get<any,TrademarkList>(Api.getAllTrademarkList)
}

// 添加品牌
export const saveTrademarkApi = (tmName:string,logoUrl:string)=>{
    return request.post<any,null>(Api.saveTrademark,{
        tmName,
        logoUrl
    })
}

// 修改品牌
export const updateTrademarkApi = (tm:TrademarkItem)=>{
    return request.put<any,null>(Api.updateTrademark,tm)
}

// 删除品牌
export const removeTrademarkApi = (id:number)=>{
    return request.delete<any,null>(`${Api.removeTrademark}/${id}`)
}